﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace boda.utilities.ValidateRules
{
    public class CtmDeviceIdRequiredAttribute : BaseAbstractAttribute
    {
        public CtmDeviceIdRequiredAttribute(string? messge) : base(messge) { }

        public override (bool, string?) DoValidate(object oValue)
        {
            try
            {
                var deviceId = Convert.ToInt32(oValue);
                if (deviceId == 0)
                {
                    return (false, Message);
                }
                else
                {
                    return (true, string.Empty);
                }
            }
            catch (Exception ex)
            {
                return (false, ex.Message);
            }
        }

    }
}
